<template>
  <el-dropdown trigger="click" @command="handleSetSize">
    <div>
      <svg-icon class-name="size-icon" icon-class="size" />
    </div>
    <template #dropdown>
      <el-dropdown-menu>
        <el-dropdown-item
          v-for="item of sizeOptions"
          :key="item.value"
          :disabled="size === item.value"
          :command="item.value"
        >
          {{ item.label }}
        </el-dropdown-item>
      </el-dropdown-menu>
    </template>
  </el-dropdown>
</template>
<script setup>
const { proxy } = getCurrentInstance()
const sizeOptions = reactive([
  { label: '大', value: 'large' },
  { label: '默认', value: 'default' },
  { label: '小', value: 'small' },
])
const size = computed(() => {
  return proxy.$store.state.app.size
})
const handleSetSize = (size) => {
  //proxy.$ELEMENT.size = size;
  proxy.$store.dispatch('app/setSize', size)
  refreshView()
  proxy.$message({
    message: '修改成功',
    type: 'success',
  })
}
const refreshView = () => {
  proxy.$store.dispatch('tabsView/delAllCachedViews', proxy.$route)
  proxy.$router.go(0)
}
</script>
